package Mooc.display;

public class Display {
    private int value = 0;
    private int limit = 0;
    private static int step=1;//类的装载，对象的创建不会影响这个值
    //所有实例共享变量,可以通过类.变量改变，或实例.变量改变

    public Display(int limit) {
        this.limit = limit;
    }

    public void increase() {
        value++;
        if (value == limit) {
            value = 0;
        }
    }

    public int getValue() { //这里如果删掉public,那么clock文件会报错
        return value;
    }
    public static void f(){
//        value++;  报错
        step++;
    }

    public static void main(String[] args) {
//        Display instance = new Display(24);
//        for (int i = 0; i < 100; i++) {
//            instance.increase();
//            System.out.println(instance.getValue());
//        }
        Display d1 = new Display(10);
        Display d2 = new Display(20);
        d1.increase();
        System.out.println(d1.getValue());//1
        System.out.println(d2.getValue());//0
        System.out.println(d1.step);//1
        System.out.println(d2.step);//1
        d1.step = 2;
        System.out.println(d1.step);//2
        System.out.println(d2.step);//2
        Display.step=3;
        System.out.println(d1.step);//3
        System.out.println(d2.step);//3
        f();
        System.out.println(d1.step);
        System.out.println(d2.step);
        Display.f();
        System.out.println(d1.step);
        System.out.println(d2.step);
    }
}

